<template>
  <el-dialog title="编辑课程" width="50%">
    <el-form :model="form" ref="formRef" label-width="120px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="课程ID:">
            <el-input v-model="form.id" clearable placeholder="请输入课程ID" type="number"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="课程名称:">
            <el-input v-model="form.courseName" clearable placeholder="请输入课程名称"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="课程价格:">
            <el-input v-model="form.price" clearable placeholder="请输入课程价格"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="课程排序:">
            <el-input v-model="form.sortNum" clearable placeholder="请输入课程排序" type="number"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否上架:">
            <el-radio-group v-model="form.status">
              <el-radio :value="1">上架</el-radio>
              <el-radio :value="0">下架</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item>
        <el-button @click="handleCancel">取消</el-button>
        <el-button type="primary" @click="handleSubmit">保存</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>


<script setup>
import {ref, defineProps, defineEmits, onMounted} from 'vue';
import {ElMessage} from "element-plus";

const props = defineProps(['course'])

const emits = defineEmits(['close'])

const form = ref({
  courseName: '',
  price: '',
  sortNum: '',
  status: '',
  id: ''
})

const formRef = ref(null)

// 取消
const handleCancel = () => {
  emits('close')
}

// 提交
const handleSubmit = () => {
  emits('close')
  ElMessage.success('保存成功')
}

onMounted(() => {
  form.value = props.course
})


</script>

<style scoped>

</style>